package com.lanou.tipsy.base;

import android.app.Application;
import android.content.Context;
import android.os.Environment;

import com.facebook.drawee.backends.pipeline.Fresco;


import java.io.File;

/**
 * Created by FengJun on 15/10/20.
 */
public class BaseApplication extends Application {
    private static Context context;
    private static String rootPath = "/mymusic";
    public static String lrcPath = "/lrc";

    @Override
    public void onCreate() {
        super.onCreate();
        if (context == null) {
            context = getApplicationContext();
        }
        Fresco.initialize(this);//加载图片工具类
        initPath();
    }

    public static Context getContext() {
        return context;
    }

    private void initPath() {
        String ROOT = "";
        if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
            ROOT = Environment.getExternalStorageDirectory().getPath();
        }
        rootPath = ROOT + rootPath;
        lrcPath = rootPath + lrcPath;
        File lrcFile = new File(lrcPath);
        if (lrcFile.exists()) {
            lrcFile.mkdirs();
        }
    }

}
